package com.uni.controllers.editors;

import com.uni.db.GenericService;
import com.uni.domain.Group;

import java.beans.PropertyEditorSupport;

public class GroupEditor extends PropertyEditorSupport {

    private GenericService<Group> groupService;


    public GroupEditor(GenericService<Group> groupService) {
        this.groupService = groupService;
    }

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
    	if(text.equals("")){
    		setValue(null);
    		return;
    	}
        setValue(groupService.get(Long.parseLong(text)));
    }

}

